//
//  ClubInfoAddressPhoneCell.m
//  SportSocial
//
//  Created by yull on 15/1/10.
//  Copyright (c) 2015年 yull. All rights reserved.
//

#import "PlaceInfoAddressPhoneCell.h"
#import "NSString+Size.h"

@implementation PlaceInfoAddressPhoneCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        CGRect rect = CGRectMake(0, 0, 70, self.contentView.height);
        self.iconImageView = [[UIImageView alloc] initWithFrame:rect];
        self.iconImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
        self.iconImageView.contentMode = UIViewContentModeCenter;
        [self.contentView addSubview:self.iconImageView];
        
        rect = CGRectMake(0, 0, 40, self.contentView.height);
        self.arrowImageView = [[UIImageView alloc] initWithFrame:rect];
        self.arrowImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
        self.arrowImageView.contentMode = UIViewContentModeCenter;
        [self.contentView addSubview:self.arrowImageView];
        
        rect = CGRectMake(self.iconImageView.right, 10, self.contentView.width - self.iconImageView.right - self.arrowImageView.width, 0);
        self.nameLabel = [[UILabel alloc] initWithFrame:rect];
        self.nameLabel.backgroundColor = [UIColor clearColor];
        self.nameLabel.font = [UIFont systemFontOfSize:16.0f];
        self.nameLabel.textColor = [UIColor blackColor];
        [self.contentView addSubview:self.nameLabel];
    }
    return self;
}

- (UIEdgeInsets)layoutMargins
{
    return UIEdgeInsetsMake(10, 0, 0, 0);
}

+ (CGFloat)calulateCellHeightWithText:(NSString *)text
{
    CGSize size = CGSizeMake(SCREEN_WIDTH - 70 - 40, CGFLOAT_MAX);
    CGSize labelSize = [text getSizeWithFont:[UIFont systemFontOfSize:16.0f] constrainedSize:size];
    return labelSize.height + 20;
}

- (void)drawCellWithText:(NSString *)text
{
    self.nameLabel.text = text;
    
    CGSize size = CGSizeMake(SCREEN_WIDTH - 70 - 40, CGFLOAT_MAX);
    CGSize labelSize = [text getSizeWithFont:[UIFont systemFontOfSize:16.0f] constrainedSize:size];
    self.nameLabel.height = labelSize.height;
}
@end
